{"version":3,"file":"static/chunks/pages/[...path]-824be5508b73091c.js","mappings":"saACA,CAAAA,OAAAC,QAAA,CAAAD,OAAAC,QAAA,MAAAC,IAAA,EACA,aACA,WACA,OAAeC,EAAQ,MACvB,EACA,yHCJO,IAAMC,EAAcC,CAAAA,EAAAA,EAAAA,aAAAA,EAAc,CAAC,GAE7BC,EAAe,IAAMC,CAAAA,EAAAA,EAAAA,UAAAA,EAAWH,GAEhCI,EAAsB,OAAC,CAAEC,SAAAA,CAAQ,CAAEC,MAAAA,CAAK,CAAE,CAAAC,EACnD,MACI,GAAAC,EAAAC,GAAA,EAACT,EAAYU,QAAQ,EAACC,MAAOL,WAAQD,GAE7C,qJCRO,IAAMO,EAAcX,CAAAA,EAAAA,SAAAA,aAAAA,EAAc,CAAC,GAI7BY,EAAsB,OAAC,CAAER,SAAAA,CAAQ,CAAES,KAAAA,CAAI,CAAE,CAAAP,EAClD,MAAO,GAAAQ,EAAAN,GAAA,EAACG,EAAYF,QAAQ,EAACC,MAAOG,WAAOT,GAC/C,WCGe,SAASW,EAAaT,CAAiC,KAAjC,CAAEU,cAAAA,CAAa,CAAEC,eAAAA,CAAc,CAAE,CAAjCX,EAC3BY,EAAYC,EAAAA,CAAc,CAACH,EAAc,QAC/C,EAII,GAAAF,EAAAN,GAAA,EAACL,EAAAA,EAAmBA,CAAAA,CAACE,MAAOY,EAAeG,SAAS,UAChD,GAAAN,EAAAN,GAAA,EAACI,EAAmBA,CAACC,KAAMI,WACvB,GAAAH,EAAAN,GAAA,EAACU,EAAAA,CAAW,GAAGD,CAAc,OAL9B,GAAAH,EAAAO,IAAA,EAACC,KAAAA,WAAG,aAAWN,EAAc,eAS5C","sources":["webpack://_N_E/?edb5","webpack://_N_E/./context/CsrfContext.js","webpack://_N_E/./context/PageContext.js","webpack://_N_E/./pages/[...path].js"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/[...path]\",\n function () {\n return require(\"private-next-pages/[...path].js\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/[...path]\"])\n });\n }\n ","import { createContext, useContext, useState } from 'react';\n\nexport const CsrfContext = createContext({});\n\nexport const useCsrfToken = () => useContext(CsrfContext);\n\nexport const CsrfContextProvider = ({ children, token }) => {\n return (\n {children}\n );\n};\n","import { createContext, useContext, useState } from 'react';\n\nexport const PageContext = createContext({});\n\nexport const usePage = () => useContext(PageContext);\n\nexport const PageContextProvider = ({ children, page }) => {\n return {children};\n};\n","import querystring from 'querystring';\nimport { getPage, getRedirect, WagtailApiResponseError } from '../api/wagtail';\nimport LazyContainers from '../containers/LazyContainers';\nimport { CsrfContextProvider } from '../context/CsrfContext';\nimport { PageContextProvider } from '../context/PageContext';\nimport composeServerSideProps from '../utils/compose-ssp';\nimport { ACCESS_TOKEN_COOKIE_NAME } from '../utils/openIDToken';\nimport cookie from 'cookie';\n\nconst isProd = process.env.NODE_ENV === 'production';\n\nexport default function CatchAllPage({ componentName, componentProps }) {\n const Component = LazyContainers[componentName];\n if (!Component) {\n return

Component {componentName} not found

;\n }\n return (\n \n \n \n \n \n );\n}\n\n// For SSR\nexport async function getServerSideProps(ctx) {\n const { req, params, res } = ctx;\n\n let path = params?.path || [];\n path = path.join('/');\n\n const { host } = req.headers;\n\n let queryParams = new URL(req.url, `https://${host}`).search;\n if (queryParams.indexOf('?') === 0) {\n queryParams = queryParams.substr(1);\n }\n queryParams = querystring.parse(queryParams);\n\n queryParams = {\n ...queryParams,\n host,\n };\n\n let cookies = {};\n if (req.headers.cookie) {\n cookies = cookie.parse(req.headers.cookie);\n }\n\n const firstPath = path.split('/')[0];\n if (['privat', 'foretag', 'private', 'company'].indexOf(firstPath) !== -1) {\n if (cookies.selectedSite != firstPath) {\n cookies['selectedSite'] = firstPath;\n }\n }\n\n if (cookies.selectedSite) {\n queryParams['selectedSite'] = cookies.selectedSite;\n }\n\n // Try to serve page\n try {\n let {\n json: { componentName, componentProps, redirect, customResponse },\n headers,\n } = await getPage(path, queryParams, {\n headers: {\n cookie: req.headers.cookie,\n },\n });\n\n // Redirect / to the subsite set in cookie, fall back to first site in tab-area\n if (componentName === 'HomePage') {\n const fallbackPath = componentProps.siteSetting.header.tabs[0].href;\n const path = req.cookies?.selectedSite\n ? '/' + req.cookies?.selectedSite + '/'\n : fallbackPath;\n\n return {\n redirect: {\n destination: path,\n isPermanent: false,\n },\n };\n }\n\n if (componentProps.onMyPages) {\n componentProps = {\n isLoggedInOnMyPages: !!cookies[ACCESS_TOKEN_COOKIE_NAME],\n ...componentProps,\n }\n }\n\n // Make sure user is logged in before serving page\n if (componentProps.onMyPages && componentProps.requireCustomerSession) {\n if (!cookies[ACCESS_TOKEN_COOKIE_NAME]) {\n return {\n redirect: {\n destination: `/api/mypages/authenticate/?next=/${path}/`,\n isPermanent: false,\n },\n };\n }\n }\n\n if (!!queryParams.error) {\n componentProps = {\n error: queryParams.error,\n ...componentProps,\n }\n }\n\n // Forward any cookie we encounter\n if (headers.get('set-cookie')) {\n res.setHeader('Set-Cookie', headers.get('set-cookie'));\n }\n\n res.setHeader(\n 'Cache-Control',\n 'public, s-maxage=30, stale-while-revalidate=59'\n );\n\n if (customResponse) {\n const { body, body64, contentType } = customResponse;\n res.setHeader('Content-Type', contentType);\n res.statusCode = 200;\n res.write(body64 ? Buffer.from(body64, 'base64') : body);\n res.end();\n\n return { props: {} };\n }\n\n if (redirect) {\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n },\n };\n }\n\n return composeServerSideProps(\n [],\n ctx,\n {\n props: {\n componentName,\n componentProps: {\n ...componentProps,\n // TODO: Remove this\n customerId: cookies.customerId || '',\n },\n },\n },\n { locale: componentProps.siteSetting.language }\n );\n } catch (err) {\n if (!(err instanceof WagtailApiResponseError)) {\n throw err;\n }\n\n // When in development, show django error page on error\n if (!isProd && err.response.status >= 500) {\n const html = await err.response.text();\n return composeServerSideProps(\n [],\n ctx,\n {\n props: {\n componentName: 'PureHtmlPage',\n componentProps: { html },\n },\n },\n { locale: ctx.locale }\n );\n }\n\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Try to serve redirect\n try {\n const { json: redirect } = await getRedirect(path, queryParams, {\n headers: {\n cookie: req.headers.cookie,\n host,\n },\n });\n const { destination, isPermanent } = redirect;\n return {\n redirect: {\n destination: destination,\n permanent: isPermanent,\n },\n };\n } catch (err) {\n if (!(err instanceof WagtailApiResponseError)) {\n throw err;\n }\n\n if (err.response.status >= 500) {\n throw err;\n }\n }\n\n // Serve 404 page\n return { notFound: true };\n}\n\n// For SSG\n/*\nexport async function getStaticProps({ params, preview, previewData }) {\n params = params || {};\n let path = params.path || [];\n path = path.join(\"/\");\n\n const { json: pageData } = await getPage(path);\n return { props: pageData }\n}\n\nexport async function getStaticPaths() {\n const { json: data } = await getAllPages();\n\n let htmlUrls = data.items.map(x => x.relativeUrl);\n htmlUrls = htmlUrls.filter(x => x);\n htmlUrls = htmlUrls.map(x => x.split(\"/\"));\n htmlUrls = htmlUrls.map(x => x.filter(y => y))\n htmlUrls = htmlUrls.filter(x => x.length)\n\n const paths = htmlUrls.map(x => (\n { params: { path: x } }\n ));\n\n return {\n paths: paths,\n fallback: false,\n };\n}\n*/\n"],"names":["window","__NEXT_P","push","__webpack_require__","CsrfContext","createContext","useCsrfToken","useContext","CsrfContextProvider","children","token","param","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__","jsx","Provider","value","PageContext","PageContextProvider","page","jsx_runtime","CatchAllPage","componentName","componentProps","Component","LazyContainers","csrfToken","jsxs","h1"],"sourceRoot":""}